package com.ruoyi.system.entity.receivevo;

import cn.hutool.core.lang.UUID;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.constant.GlobalConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.EnclosureAlert;
import com.ruoyi.system.domain.KeyAlert;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 围栏报警对象 enclosure_alert
 * 
 * @author ruoyi
 * @date 2025-09-17
 */
@Data
public class ReceiveEnclosureAlert implements Serializable
{
    private static final long serialVersionUID = 1L;

    private String id;
    private String companyCode;
    private String zoneId;
    // 超员报警-1，缺员报警-2，缺岗报警-3
    private String alarmType;
    private String alarmTime;
    private String dispelTime;
    // 报警描述， 必填
    private String describe;
    private String deleted;

    /** 创建人 */
    private String createdBy;
    /** 创建时间 */
    private String createDate;
    /** 创建人 */
    private String updateBy;
    /** 创建时间 */
    private String updateDate;

    public static ReceiveEnclosureAlert enclosureAlertToReceiveEnclosureAlert(EnclosureAlert enclosureAlert) {
        ReceiveEnclosureAlert vo = new ReceiveEnclosureAlert();
        vo.setId(UUID.randomUUID().toString());
        vo.setCompanyCode(GlobalConstants.COMPANY_CODE);
//        vo.setZoneId();
        String alarmTime = enclosureAlert.getRaiseTime()==null ? DateUtils.getTime() : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getRaiseTime());
        String stopTime = enclosureAlert.getStopTime()==null ? DateUtils.getTime() : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getStopTime());
        vo.setAlarmTime(alarmTime);
        vo.setDispelTime(stopTime);
        vo.setDescribe(enclosureAlert.getEnclosureName() + "内触发" + enclosureAlert.getTriggerName());
        vo.setDeleted("0");
        vo.setCreatedBy(enclosureAlert.getCreatedBy());
        String createdTime = enclosureAlert.getCreatedTime()==null ? DateUtils.getTime() : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getCreatedTime());
        vo.setCreateDate(createdTime);
        vo.setUpdateBy(enclosureAlert.getUpdateBy());
        String updateTime = enclosureAlert.getUpdateTime()==null ? DateUtils.getTime() : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", enclosureAlert.getUpdateTime());
        vo.setUpdateDate(updateTime);
        return vo;
    }

}
